import {
  exportUrl,
  downloadTemplateUrl,
  getOrderTypeList,
  getOrderStatusList,
  getSignatureFlagList,
  getCurrentWarehouseCode,
} from "@/api/outbound/wmsOutChargeAccount";

import { exportExcel } from "@/utils/judge";

// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl,
    //auth: "auth:operlog:export", //权限字段
  },
  // {
  //   name: "新增",
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "add", //点击时返回的标识
  // },
  // {
  //   name: "删除",
  //   type: "danger",
  //   icon: "el-icon-delete",
  //   handleName: "deleteBatch", //点击时返回的标识
  //   isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  // },
  // {
  //   name: "导入",
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "import", //点击时返回的标识
  // },
];
// 行末按钮配置
export const rowConfig = [
  // {
  //   name: "修改",
  //   type: "primary",
  //   class: "row-btn-primary",
  //   handleName: "edit", //点击时返回的标识
  // },
  {
    name: $i18n.t("wmsOutChargeAccount.signaturePicture"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail", //点击时返回的标识
    disabled(data) {
      return data.signatureFlag == "2" ? true : false;
    },
  },
  // {
  //   name: "删除",
  //   type: "danger",
  //   class: "row-btn-danger",
  //   handleName: "delete", //点击时返回的标识
  // },
];
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    warehouseCode: {
      type: "select",
      label: $i18n.t("common.warehouseCode"),
      prop: {
        value: "modelingCode",
        text: "modelingName",
      },
      options: async (data) => {
        const res = await getCurrentWarehouseCode();
        let list = res.data.result || [];
        list.forEach((val) => {
          val.modelingName = `${val.modelingCode}-${val.modelingName}`;
        });
        return list;
      },
    },
    orderNo: {
      type: "input",
      label: $i18n.t("wmsOutChargeAccount.orderNo"),
    },
    orderType: {
      type: "select",
      label: $i18n.t("wmsOutChargeAccount.orderType"),
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getOrderTypeList();
        return list.data.result;
      },
    },
    orderStatus: {
      type: "select",
      label: $i18n.t("wmsOutChargeAccount.orderStatus"),
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getOrderStatusList();
        return list.data.result;
      },
    },
    signatureFlag: {
      type: "select",
      label: $i18n.t("wmsOutChargeAccount.signatureType"),
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getSignatureFlagList();
        return list.data.result;
      },
    },
    goodsCode: {
      type: "input",
      label: $i18n.t("wmsOutChargeAccount.goodsCode"),
    },
    goodsName: {
      type: "input",
      label: $i18n.t("wmsOutChargeAccount.goodsName"),
    },
  },
};
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    id: {
      type: "number",
      label: "",
      layout: 12,
      required: true,
    },
    orderNo: {
      type: "input",
      label: $i18n.t("wmsOutChargeAccount.orderNo"),
      layout: 12,
      required: false,
    },
    orderType: {
      type: "select",
      label: $i18n.t("wmsOutChargeAccount.orderType"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getOrderTypeList();
        return list.data.result;
      },
    },
    orderStatus: {
      type: "select",
      label: $i18n.t("wmsOutChargeAccount.orderStatus"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getOrderStatusList();
        return list.data.result;
      },
    },
    signatureFlag: {
      type: "select",
      label: $i18n.t("wmsOutChargeAccount.signatureFlag"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getSignatureFlagList();
        return list.data.result;
      },
    },
    signatureId: {
      type: "number",
      label: $i18n.t("wmsOutChargeAccount.signatureId"),
      layout: 12,
      required: false,
    },
    goodsCode: {
      type: "input",
      label: $i18n.t("wmsOutChargeAccount.goodsCode"),
      layout: 12,
      required: false,
    },
    goodsName: {
      type: "input",
      label: $i18n.t("wmsOutChargeAccount.goodsName"),
      layout: 12,
      required: false,
    },
    planAmount: {
      type: "number",
      label: $i18n.t("wmsOutChargeAccount.planAmount"),
      layout: 12,
      required: false,
    },
    realAmount: {
      type: "number",
      label: $i18n.t("wmsOutChargeAccount.realAmount"),
      layout: 12,
      required: false,
    },
    warehouseCode: {
      type: "input",
      label: $i18n.t("wmsOutChargeAccount.warehouseCode"),
      layout: 12,
      required: false,
    },
    unit: {
      type: "input",
      label: $i18n.t("wmsOutChargeAccount.unit"),
      layout: 12,
      required: false,
    },
    factoryCode: {
      type: "input",
      label: $i18n.t('wmsOutChargeAccount.factoryCodeTenantCode'),
      layout: 12,
      required: false,
    },
    customerCode: {
      type: "input",
      label: $i18n.t("wmsOutChargeAccount.customerCode"),
      layout: 12,
      required: false,
    },
    customerName: {
      type: "input",
      label: $i18n.t("wmsOutChargeAccount.customerName"),
      layout: 12,
      required: false,
    },
  },
};
//导入数据
export const importFormDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    model: {
      type: "button",
      label: "",
      layout: 24,
      required: false,
      title: $i18n.t('common.downloadTemplate'),
      style: {
        color: "#1867c0",
        fontSize: "14px",
      },
      on: {
        click: () => {
          exportExcel(downloadTemplateUrl);
        },
      },
    },
    file: {
      type: "input",
      label: $i18n.t("wmsOutChargeAccount.file"),
      layout: 24,
      // required: true,
    },
  },
};
